package cn.toolck.controller;

import cn.toolck.service.LagouAuthCodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CodeController
 * @Description TODO
 * @Author Toolck Rin
 * @Date 2021/5/19 17:47
 * @Version 1.0
 **/
@RestController
@RequestMapping("/code")
public class CodeController {
    @Autowired
    private LagouAuthCodeService lagouAuthCodeService;

    /**
     * ⽣成验证码并发送到对应邮箱
     *
     * @param email 邮箱
     * @return 成功true，失败false
     */
    @GetMapping("/create/{email}")
    public Boolean create(@PathVariable("email") String email) {
        return lagouAuthCodeService.createAndSend(email);
    }

    /**
     * 校验验证码是否正确，
     *
     * @param email 邮箱
     * @param code  验证码
     * @return 0正确1错误2超时
     */
/*    @PostMapping("/validate/{email}/{code}")
    public int validate(@PathVariable("email") String email, @PathVariable("code") String code) {
        return lagouAuthCodeService.validate(email, code);
    }*/
}
